/*
 * Copyright (c) 2025 Huawei Device Co., Ltd.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

#include "ohos.multimodalInput.keyCode.impl.h"

#undef MMI_LOG_TAG
#define MMI_LOG_TAG "ohos.multimodalInput.keyCode.impl"

namespace OHOS {
namespace MMI {

const static std::map<int32_t, KeyCode> KEY_CODE_TRANSFORMATION = {
    { KEYCODE_FN_ETS,                        KeyCode::key_t::KEYCODE_FN },
    { KEYCODE_UNKNOWN_ETS,                   KeyCode::key_t::KEYCODE_UNKNOWN },
    { KEYCODE_HOME_ETS,                      KeyCode::key_t::KEYCODE_HOME },
    { KEYCODE_BACK_ETS,                      KeyCode::key_t::KEYCODE_BACK },
    { KEYCODE_SEARCH_ETS,                    KeyCode::key_t::KEYCODE_SEARCH  },
    { KEYCODE_MEDIA_PLAY_PAUSE_ETS,          KeyCode::key_t::KEYCODE_MEDIA_PLAY_PAUSE },
    { KEYCODE_MEDIA_STOP_ETS,                KeyCode::key_t::KEYCODE_MEDIA_STOP },
    { KEYCODE_MEDIA_NEXT_ETS,                KeyCode::key_t::KEYCODE_MEDIA_NEXT },
    { KEYCODE_MEDIA_PREVIOUS_ETS,            KeyCode::key_t::KEYCODE_MEDIA_PREVIOUS },
    { KEYCODE_MEDIA_REWIND_ETS,              KeyCode::key_t::KEYCODE_MEDIA_REWIND },
    { KEYCODE_MEDIA_FAST_FORWARD_ETS,        KeyCode::key_t::KEYCODE_MEDIA_FAST_FORWARD },
    { KEYCODE_VOLUME_UP_ETS,                 KeyCode::key_t::KEYCODE_VOLUME_UP },
    { KEYCODE_VOLUME_DOWN_ETS,               KeyCode::key_t::KEYCODE_VOLUME_DOWN },
    { KEYCODE_POWER_ETS,                     KeyCode::key_t::KEYCODE_POWER  },
    { KEYCODE_CAMERA_ETS,                    KeyCode::key_t::KEYCODE_CAMERA },
    { KEYCODE_VOLUME_MUTE_ETS,               KeyCode::key_t::KEYCODE_VOLUME_MUTE },
    { KEYCODE_MUTE_ETS,                      KeyCode::key_t::KEYCODE_MUTE },
    { KEYCODE_BRIGHTNESS_UP_ETS,             KeyCode::key_t::KEYCODE_BRIGHTNESS_UP },
    { KEYCODE_BRIGHTNESS_DOWN_ETS,           KeyCode::key_t::KEYCODE_BRIGHTNESS_DOWN },
    { KEYCODE_0_ETS,                         KeyCode::key_t::KEYCODE_0 },
    { KEYCODE_1_ETS,                         KeyCode::key_t::KEYCODE_1 },
    { KEYCODE_2_ETS,                         KeyCode::key_t::KEYCODE_2 },
    { KEYCODE_3_ETS,                         KeyCode::key_t::KEYCODE_3 },
    { KEYCODE_4_ETS,                         KeyCode::key_t::KEYCODE_4 },
    { KEYCODE_5_ETS,                         KeyCode::key_t::KEYCODE_5 },
    { KEYCODE_6_ETS,                         KeyCode::key_t::KEYCODE_6 },
    { KEYCODE_7_ETS,                         KeyCode::key_t::KEYCODE_7 },
    { KEYCODE_8_ETS,                         KeyCode::key_t::KEYCODE_8 },
    { KEYCODE_9_ETS,                         KeyCode::key_t::KEYCODE_9 },
    { KEYCODE_STAR_ETS,                      KeyCode::key_t::KEYCODE_STAR },
    { KEYCODE_POUND_ETS,                     KeyCode::key_t::KEYCODE_POUND },
    { KEYCODE_DPAD_UP_ETS,                   KeyCode::key_t::KEYCODE_DPAD_UP },
    { KEYCODE_DPAD_LEFT_ETS,                 KeyCode::key_t::KEYCODE_DPAD_LEFT },
    { KEYCODE_DPAD_RIGHT_ETS,                KeyCode::key_t::KEYCODE_DPAD_RIGHT },
    { KEYCODE_DPAD_CENTER_ETS,               KeyCode::key_t::KEYCODE_DPAD_CENTER },
    { KEYCODE_A_ETS,                         KeyCode::key_t::KEYCODE_A },
    { KEYCODE_B_ETS,                         KeyCode::key_t::KEYCODE_B },
    { KEYCODE_C_ETS,                         KeyCode::key_t::KEYCODE_C },
    { KEYCODE_D_ETS,                         KeyCode::key_t::KEYCODE_D },
    { KEYCODE_E_ETS,                         KeyCode::key_t::KEYCODE_E },
    { KEYCODE_F_ETS,                         KeyCode::key_t::KEYCODE_F },
    { KEYCODE_G_ETS,                         KeyCode::key_t::KEYCODE_G },
    { KEYCODE_H_ETS,                         KeyCode::key_t::KEYCODE_H },
    { KEYCODE_I_ETS,                         KeyCode::key_t::KEYCODE_I },
    { KEYCODE_J_ETS,                         KeyCode::key_t::KEYCODE_J },
    { KEYCODE_K_ETS,                         KeyCode::key_t::KEYCODE_K },
    { KEYCODE_L_ETS,                         KeyCode::key_t::KEYCODE_L },
    { KEYCODE_M_ETS,                         KeyCode::key_t::KEYCODE_M },
    { KEYCODE_N_ETS,                         KeyCode::key_t::KEYCODE_N },
    { KEYCODE_O_ETS,                         KeyCode::key_t::KEYCODE_O },
    { KEYCODE_P_ETS,                         KeyCode::key_t::KEYCODE_P },
    { KEYCODE_Q_ETS,                         KeyCode::key_t::KEYCODE_Q },
    { KEYCODE_R_ETS,                         KeyCode::key_t::KEYCODE_R },
    { KEYCODE_S_ETS,                         KeyCode::key_t::KEYCODE_S },
    { KEYCODE_T_ETS,                         KeyCode::key_t::KEYCODE_T },
    { KEYCODE_U_ETS,                         KeyCode::key_t::KEYCODE_U },
    { KEYCODE_V_ETS,                         KeyCode::key_t::KEYCODE_V },
    { KEYCODE_W_ETS,                         KeyCode::key_t::KEYCODE_W },
    { KEYCODE_X_ETS,                         KeyCode::key_t::KEYCODE_X },
    { KEYCODE_Y_ETS,                         KeyCode::key_t::KEYCODE_Y },
    { KEYCODE_Z_ETS,                         KeyCode::key_t::KEYCODE_Z },
    { KEYCODE_COMMA_ETS,                     KeyCode::key_t::KEYCODE_COMMA },
    { KEYCODE_PERIOD_ETS,                    KeyCode::key_t::KEYCODE_PERIOD },
    { KEYCODE_ALT_LEFT_ETS,                  KeyCode::key_t::KEYCODE_ALT_LEFT },
    { KEYCODE_ALT_RIGHT_ETS,                 KeyCode::key_t::KEYCODE_ALT_RIGHT },
    { KEYCODE_SHIFT_LEFT_ETS,                KeyCode::key_t::KEYCODE_SHIFT_LEFT },
    { KEYCODE_SHIFT_RIGHT_ETS,               KeyCode::key_t::KEYCODE_SHIFT_RIGHT },
    { KEYCODE_TAB_ETS,                       KeyCode::key_t::KEYCODE_TAB },
    { KEYCODE_SPACE_ETS,                     KeyCode::key_t::KEYCODE_SPACE },
    { KEYCODE_SYM_ETS,                       KeyCode::key_t::KEYCODE_SYM },
    { KEYCODE_EXPLORER_ETS,                  KeyCode::key_t::KEYCODE_EXPLORER },
    { KEYCODE_ENVELOPE_ETS,                  KeyCode::key_t::KEYCODE_ENVELOPE },
    { KEYCODE_ENTER_ETS,                     KeyCode::key_t::KEYCODE_ENTER },
    { KEYCODE_DEL_ETS,                       KeyCode::key_t::KEYCODE_DEL },
    { KEYCODE_GRAVE_ETS,                     KeyCode::key_t::KEYCODE_GRAVE },
    { KEYCODE_MINUS_ETS,                     KeyCode::key_t::KEYCODE_MINUS },
    { KEYCODE_EQUALS_ETS,                    KeyCode::key_t::KEYCODE_EQUALS },
    { KEYCODE_LEFT_BRACKET_ETS,              KeyCode::key_t::KEYCODE_LEFT_BRACKET },
    { KEYCODE_RIGHT_BRACKET_ETS,             KeyCode::key_t::KEYCODE_RIGHT_BRACKET },
    { KEYCODE_BACKSLASH_ETS,                 KeyCode::key_t::KEYCODE_BACKSLASH },
    { KEYCODE_SEMICOLON_ETS,                 KeyCode::key_t::KEYCODE_SEMICOLON },
    { KEYCODE_APOSTROPHE_ETS,                KeyCode::key_t::KEYCODE_APOSTROPHE },
    { KEYCODE_SLASH_ETS,                     KeyCode::key_t::KEYCODE_SLASH },
    { KEYCODE_AT_ETS,                        KeyCode::key_t::KEYCODE_AT },
    { KEYCODE_PLUS_ETS,                      KeyCode::key_t::KEYCODE_PLUS },
    { KEYCODE_MENU_ETS,                      KeyCode::key_t::KEYCODE_MENU },
    { KEYCODE_PAGE_UP_ETS,                   KeyCode::key_t::KEYCODE_PAGE_UP },
    { KEYCODE_PAGE_DOWN_ETS,                 KeyCode::key_t::KEYCODE_PAGE_DOWN },
    { KEYCODE_ESCAPE_ETS,                    KeyCode::key_t::KEYCODE_ESCAPE },
    { KEYCODE_FORWARD_DEL_ETS,               KeyCode::key_t::KEYCODE_FORWARD_DEL },
    { KEYCODE_CTRL_LEFT_ETS,                 KeyCode::key_t::KEYCODE_CTRL_LEFT },
    { KEYCODE_CTRL_RIGHT_ETS,                KeyCode::key_t::KEYCODE_CTRL_RIGHT },
    { KEYCODE_CAPS_LOCK_ETS,                 KeyCode::key_t::KEYCODE_CAPS_LOCK },
    { KEYCODE_SCROLL_LOCK_ETS,               KeyCode::key_t::KEYCODE_SCROLL_LOCK },
    { KEYCODE_META_LEFT_ETS,                 KeyCode::key_t::KEYCODE_META_LEFT },
    { KEYCODE_META_RIGHT_ETS,                KeyCode::key_t::KEYCODE_META_RIGHT },
    { KEYCODE_FUNCTION_ETS,                  KeyCode::key_t::KEYCODE_FUNCTION },
    { KEYCODE_SYSRQ_ETS,                     KeyCode::key_t::KEYCODE_SYSRQ },
    { KEYCODE_BREAK_ETS,                     KeyCode::key_t::KEYCODE_BREAK },
    { KEYCODE_MOVE_HOME_ETS,                 KeyCode::key_t::KEYCODE_MOVE_HOME },
    { KEYCODE_MOVE_END_ETS,                  KeyCode::key_t::KEYCODE_MOVE_END },
    { KEYCODE_INSERT_ETS,                    KeyCode::key_t::KEYCODE_INSERT },
    { KEYCODE_FORWARD_ETS,                   KeyCode::key_t::KEYCODE_FORWARD },
    { KEYCODE_MEDIA_PLAY_ETS,                KeyCode::key_t::KEYCODE_MEDIA_PLAY },
    { KEYCODE_MEDIA_PAUSE_ETS,               KeyCode::key_t::KEYCODE_MEDIA_PAUSE },
    { KEYCODE_MEDIA_CLOSE_ETS,               KeyCode::key_t::KEYCODE_MEDIA_CLOSE },
    { KEYCODE_MEDIA_EJECT_ETS,               KeyCode::key_t::KEYCODE_MEDIA_EJECT },
    { KEYCODE_MEDIA_RECORD_ETS,              KeyCode::key_t::KEYCODE_MEDIA_RECORD },
    { KEYCODE_F1_ETS,                        KeyCode::key_t::KEYCODE_F1 },
    { KEYCODE_F2_ETS,                        KeyCode::key_t::KEYCODE_F2 },
    { KEYCODE_F3_ETS,                        KeyCode::key_t::KEYCODE_F3 },
    { KEYCODE_F4_ETS,                        KeyCode::key_t::KEYCODE_F4 },
    { KEYCODE_F5_ETS,                        KeyCode::key_t::KEYCODE_F5 },
    { KEYCODE_F6_ETS,                        KeyCode::key_t::KEYCODE_F6 },
    { KEYCODE_F7_ETS,                        KeyCode::key_t::KEYCODE_F7 },
    { KEYCODE_F8_ETS,                        KeyCode::key_t::KEYCODE_F8 },
    { KEYCODE_F9_ETS,                        KeyCode::key_t::KEYCODE_F9 },
    { KEYCODE_F10_ETS,                       KeyCode::key_t::KEYCODE_F10 },
    { KEYCODE_F11_ETS,                       KeyCode::key_t::KEYCODE_F11 },
    { KEYCODE_F12_ETS,                       KeyCode::key_t::KEYCODE_F12 },
    { KEYCODE_NUM_LOCK_ETS,                  KeyCode::key_t::KEYCODE_NUM_LOCK },
    { KEYCODE_NUMPAD_0_ETS,                  KeyCode::key_t::KEYCODE_NUMPAD_0 },
    { KEYCODE_NUMPAD_1_ETS,                  KeyCode::key_t::KEYCODE_NUMPAD_1 },
    { KEYCODE_NUMPAD_2_ETS,                  KeyCode::key_t::KEYCODE_NUMPAD_2 },
    { KEYCODE_NUMPAD_3_ETS,                  KeyCode::key_t::KEYCODE_NUMPAD_3 },
    { KEYCODE_NUMPAD_4_ETS,                  KeyCode::key_t::KEYCODE_NUMPAD_4 },
    { KEYCODE_NUMPAD_5_ETS,                  KeyCode::key_t::KEYCODE_NUMPAD_5 },
    { KEYCODE_NUMPAD_6_ETS,                  KeyCode::key_t::KEYCODE_NUMPAD_6 },
    { KEYCODE_NUMPAD_7_ETS,                  KeyCode::key_t::KEYCODE_NUMPAD_7 },
    { KEYCODE_NUMPAD_8_ETS,                  KeyCode::key_t::KEYCODE_NUMPAD_8 },
    { KEYCODE_NUMPAD_9_ETS,                  KeyCode::key_t::KEYCODE_NUMPAD_9 },
    { KEYCODE_NUMPAD_DIVIDE_ETS,             KeyCode::key_t::KEYCODE_NUMPAD_DIVIDE },
    { KEYCODE_NUMPAD_MULTIPLY_ETS,           KeyCode::key_t::KEYCODE_NUMPAD_MULTIPLY },
    { KEYCODE_NUMPAD_SUBTRACT_ETS,           KeyCode::key_t::KEYCODE_NUMPAD_SUBTRACT },
    { KEYCODE_NUMPAD_ADD_ETS,                KeyCode::key_t::KEYCODE_NUMPAD_ADD },
    { KEYCODE_NUMPAD_DOT_ETS,                KeyCode::key_t::KEYCODE_NUMPAD_DOT },
    { KEYCODE_NUMPAD_COMMA_ETS,              KeyCode::key_t::KEYCODE_NUMPAD_COMMA },
    { KEYCODE_NUMPAD_ENTER_ETS,              KeyCode::key_t::KEYCODE_NUMPAD_ENTER },
    { KEYCODE_NUMPAD_EQUALS_ETS,             KeyCode::key_t::KEYCODE_NUMPAD_EQUALS },
    { KEYCODE_NUMPAD_LEFT_PAREN_ETS,         KeyCode::key_t::KEYCODE_NUMPAD_LEFT_PAREN },
    { KEYCODE_NUMPAD_RIGHT_PAREN_ETS,        KeyCode::key_t::KEYCODE_NUMPAD_RIGHT_PAREN },
    { KEYCODE_VIRTUAL_MULTITASK_ETS,         KeyCode::key_t::KEYCODE_VIRTUAL_MULTITASK },
    { KEYCODE_BUTTON_A_ETS,                  KeyCode::key_t::KEYCODE_BUTTON_A },
    { KEYCODE_BUTTON_B_ETS,                  KeyCode::key_t::KEYCODE_BUTTON_B },
    { KEYCODE_BUTTON_X_ETS,                  KeyCode::key_t::KEYCODE_BUTTON_X },
    { KEYCODE_BUTTON_Y_ETS,                  KeyCode::key_t::KEYCODE_BUTTON_Y },
    { KEYCODE_BUTTON_L1_ETS,                 KeyCode::key_t::KEYCODE_BUTTON_L1 },
    { KEYCODE_BUTTON_R1_ETS,                 KeyCode::key_t::KEYCODE_BUTTON_R1 },
    { KEYCODE_BUTTON_L2_ETS,                 KeyCode::key_t::KEYCODE_BUTTON_L2 },
    { KEYCODE_BUTTON_R2_ETS,                 KeyCode::key_t::KEYCODE_BUTTON_R2 },
    { KEYCODE_BUTTON_SELECT_ETS,             KeyCode::key_t::KEYCODE_BUTTON_SELECT },
    { KEYCODE_BUTTON_START_ETS,              KeyCode::key_t::KEYCODE_BUTTON_START },
    { KEYCODE_BUTTON_MODE_ETS,               KeyCode::key_t::KEYCODE_BUTTON_MODE },
    { KEYCODE_BUTTON_THUMBL_ETS,             KeyCode::key_t::KEYCODE_BUTTON_THUMBL },
    { KEYCODE_BUTTON_THUMBR_ETS,             KeyCode::key_t::KEYCODE_BUTTON_THUMBR },
    { KEYCODE_SLEEP_ETS,                     KeyCode::key_t::KEYCODE_SLEEP },
    { KEYCODE_ZENKAKU_HANKAKU_ETS,           KeyCode::key_t::KEYCODE_ZENKAKU_HANKAKU },
    { KEYCODE_102ND_ETS,                     KeyCode::key_t::KEYCODE_102ND },
    { KEYCODE_RO_ETS,                        KeyCode::key_t::KEYCODE_RO },
    { KEYCODE_KATAKANA_ETS,                  KeyCode::key_t::KEYCODE_KATAKANA },
    { KEYCODE_HIRAGANA_ETS,                  KeyCode::key_t::KEYCODE_HIRAGANA },
    { KEYCODE_HENKAN_ETS,                    KeyCode::key_t::KEYCODE_HENKAN },
    { KEYCODE_KATAKANA_HIRAGANA_ETS,         KeyCode::key_t::KEYCODE_KATAKANA_HIRAGANA },
    { KEYCODE_MUHENKAN_ETS,                  KeyCode::key_t::KEYCODE_MUHENKAN },
    { KEYCODE_LINEFEED_ETS,                  KeyCode::key_t::KEYCODE_LINEFEED },
    { KEYCODE_MACRO_ETS,                     KeyCode::key_t::KEYCODE_MACRO },
    { KEYCODE_NUMPAD_PLUSMINUS_ETS,          KeyCode::key_t::KEYCODE_NUMPAD_PLUSMINUS },
    { KEYCODE_SCALE_ETS,                     KeyCode::key_t::KEYCODE_SCALE },
    { KEYCODE_HANGUEL_ETS,                   KeyCode::key_t::KEYCODE_HANGUEL },
    { KEYCODE_HANJA_ETS,                     KeyCode::key_t::KEYCODE_HANJA },
    { KEYCODE_YEN_ETS,                       KeyCode::key_t::KEYCODE_YEN },
    { KEYCODE_STOP_ETS,                      KeyCode::key_t::KEYCODE_STOP },
    { KEYCODE_AGAIN_ETS,                     KeyCode::key_t::KEYCODE_AGAIN },
    { KEYCODE_PROPS_ETS,                     KeyCode::key_t::KEYCODE_PROPS },
    { KEYCODE_UNDO_ETS,                      KeyCode::key_t::KEYCODE_UNDO },
    { KEYCODE_COPY_ETS,                      KeyCode::key_t::KEYCODE_COPY },
    { KEYCODE_OPEN_ETS,                      KeyCode::key_t::KEYCODE_OPEN },
    { KEYCODE_PASTE_ETS,                     KeyCode::key_t::KEYCODE_PASTE },
    { KEYCODE_FIND_ETS,                      KeyCode::key_t::KEYCODE_FIND },
    { KEYCODE_CUT_ETS,                       KeyCode::key_t::KEYCODE_CUT },
    { KEYCODE_HELP_ETS,                      KeyCode::key_t::KEYCODE_HELP },
    { KEYCODE_CALC_ETS,                      KeyCode::key_t::KEYCODE_CALC },
    { KEYCODE_FILE_ETS,                      KeyCode::key_t::KEYCODE_FILE },
    { KEYCODE_BOOKMARKS_ETS,                 KeyCode::key_t::KEYCODE_BOOKMARKS },
    { KEYCODE_NEXT_ETS,                      KeyCode::key_t::KEYCODE_NEXT },
    { KEYCODE_PLAYPAUSE_ETS,                 KeyCode::key_t::KEYCODE_PLAYPAUSE },
    { KEYCODE_PREVIOUS_ETS,                  KeyCode::key_t::KEYCODE_PREVIOUS },
    { KEYCODE_STOPCD_ETS,                    KeyCode::key_t::KEYCODE_STOPCD },
    { KEYCODE_CONFIG_ETS,                    KeyCode::key_t::KEYCODE_CONFIG },
    { KEYCODE_REFRESH_ETS,                   KeyCode::key_t::KEYCODE_REFRESH },
    { KEYCODE_EXIT_ETS,                      KeyCode::key_t::KEYCODE_EXIT },
    { KEYCODE_EDIT_ETS,                      KeyCode::key_t::KEYCODE_EDIT },
    { KEYCODE_SCROLLUP_ETS,                  KeyCode::key_t::KEYCODE_SCROLLUP },
    { KEYCODE_SCROLLDOWN_ETS,                KeyCode::key_t::KEYCODE_SCROLLDOWN },
    { KEYCODE_NEW_ETS,                       KeyCode::key_t::KEYCODE_NEW },
    { KEYCODE_REDO_ETS,                      KeyCode::key_t::KEYCODE_REDO },
    { KEYCODE_CLOSE_ETS,                     KeyCode::key_t::KEYCODE_CLOSE },
    { KEYCODE_PLAY_ETS,                      KeyCode::key_t::KEYCODE_PLAY },
    { KEYCODE_BASSBOOST_ETS,                 KeyCode::key_t::KEYCODE_BASSBOOST },
    { KEYCODE_PRINT_ETS,                     KeyCode::key_t::KEYCODE_PRINT },
    { KEYCODE_CHAT_ETS,                      KeyCode::key_t::KEYCODE_CHAT },
    { KEYCODE_FINANCE_ETS,                   KeyCode::key_t::KEYCODE_FINANCE },
    { KEYCODE_CANCEL_ETS,                    KeyCode::key_t::KEYCODE_CANCEL },
    { KEYCODE_KBDILLUM_TOGGLE_ETS,           KeyCode::key_t::KEYCODE_KBDILLUM_TOGGLE },
    { KEYCODE_KBDILLUM_DOWN_ETS,             KeyCode::key_t::KEYCODE_KBDILLUM_DOWN },
    { KEYCODE_KBDILLUM_UP_ETS,               KeyCode::key_t::KEYCODE_KBDILLUM_UP },
    { KEYCODE_SEND_ETS,                      KeyCode::key_t::KEYCODE_SEND },
    { KEYCODE_REPLY_ETS,                     KeyCode::key_t::KEYCODE_REPLY },
    { KEYCODE_FORWARDMAIL_ETS,               KeyCode::key_t::KEYCODE_FORWARDMAIL },
    { KEYCODE_SAVE_ETS,                      KeyCode::key_t::KEYCODE_SAVE },
    { KEYCODE_DOCUMENTS_ETS,                 KeyCode::key_t::KEYCODE_DOCUMENTS },
    { KEYCODE_VIDEO_NEXT_ETS,                KeyCode::key_t::KEYCODE_VIDEO_NEXT },
    { KEYCODE_VIDEO_PREV_ETS,                KeyCode::key_t::KEYCODE_VIDEO_PREV },
    { KEYCODE_BRIGHTNESS_CYCLE_ETS,          KeyCode::key_t::KEYCODE_BRIGHTNESS_CYCLE },
    { KEYCODE_BRIGHTNESS_ZERO_ETS,           KeyCode::key_t::KEYCODE_BRIGHTNESS_ZERO },
    { KEYCODE_DISPLAY_OFF_ETS,               KeyCode::key_t::KEYCODE_DISPLAY_OFF },
    { KEYCODE_BTN_MISC_ETS,                  KeyCode::key_t::KEYCODE_BTN_MISC },
    { KEYCODE_GOTO_ETS,                      KeyCode::key_t::KEYCODE_GOTO },
    { KEYCODE_INFO_ETS,                      KeyCode::key_t::KEYCODE_INFO },
    { KEYCODE_PROGRAM_ETS,                   KeyCode::key_t::KEYCODE_PROGRAM },
    { KEYCODE_PVR_ETS,                       KeyCode::key_t::KEYCODE_PVR },
    { KEYCODE_SUBTITLE_ETS,                  KeyCode::key_t::KEYCODE_SUBTITLE },
    { KEYCODE_FULL_SCREEN_ETS,               KeyCode::key_t::KEYCODE_FULL_SCREEN },
    { KEYCODE_KEYBOARD_ETS,                  KeyCode::key_t::KEYCODE_KEYBOARD },
    { KEYCODE_ASPECT_RATIO_ETS,              KeyCode::key_t::KEYCODE_ASPECT_RATIO },
    { KEYCODE_PC_ETS,                        KeyCode::key_t::KEYCODE_PC },
    { KEYCODE_TV_ETS,                        KeyCode::key_t::KEYCODE_TV },
    { KEYCODE_TV2_ETS,                       KeyCode::key_t::KEYCODE_TV2 },
    { KEYCODE_VCR_ETS,                       KeyCode::key_t::KEYCODE_VCR },
    { KEYCODE_VCR2_ETS,                      KeyCode::key_t::KEYCODE_VCR2 },
    { KEYCODE_SAT_ETS,                       KeyCode::key_t::KEYCODE_SAT },
    { KEYCODE_CD_ETS,                        KeyCode::key_t::KEYCODE_CD },
    { KEYCODE_TAPE_ETS,                      KeyCode::key_t::KEYCODE_TAPE },
    { KEYCODE_TUNER_ETS,                     KeyCode::key_t::KEYCODE_TUNER },
    { KEYCODE_PLAYER_ETS,                    KeyCode::key_t::KEYCODE_PLAYER },
    { KEYCODE_DVD_ETS,                       KeyCode::key_t::KEYCODE_DVD },
    { KEYCODE_AUDIO_ETS,                     KeyCode::key_t::KEYCODE_AUDIO },
    { KEYCODE_VIDEO_ETS,                     KeyCode::key_t::KEYCODE_VIDEO },
    { KEYCODE_MEMO_ETS,                      KeyCode::key_t::KEYCODE_MEMO },
    { KEYCODE_CALENDAR_ETS,                  KeyCode::key_t::KEYCODE_CALENDAR },
    { KEYCODE_RED_ETS,                       KeyCode::key_t::KEYCODE_RED },
    { KEYCODE_GREEN_ETS,                     KeyCode::key_t::KEYCODE_GREEN },
    { KEYCODE_YELLOW_ETS,                    KeyCode::key_t::KEYCODE_YELLOW },
    { KEYCODE_BLUE_ETS,                      KeyCode::key_t::KEYCODE_BLUE },
    { KEYCODE_CHANNELUP_ETS,                 KeyCode::key_t::KEYCODE_CHANNELUP },
    { KEYCODE_CHANNELDOWN_ETS,               KeyCode::key_t::KEYCODE_CHANNELDOWN },
    { KEYCODE_LAST_ETS,                      KeyCode::key_t::KEYCODE_LAST },
    { KEYCODE_RESTART_ETS,                   KeyCode::key_t::KEYCODE_RESTART },
    { KEYCODE_SLOW_ETS,                      KeyCode::key_t::KEYCODE_SLOW },
    { KEYCODE_SHUFFLE_ETS,                   KeyCode::key_t::KEYCODE_SHUFFLE },
    { KEYCODE_VIDEOPHONE_ETS,                KeyCode::key_t::KEYCODE_VIDEOPHONE },
    { KEYCODE_GAMES_ETS,                     KeyCode::key_t::KEYCODE_GAMES },
    { KEYCODE_ZOOMIN_ETS,                    KeyCode::key_t::KEYCODE_ZOOMIN },
    { KEYCODE_ZOOMOUT_ETS,                   KeyCode::key_t::KEYCODE_ZOOMOUT },
    { KEYCODE_ZOOMRESET_ETS,                 KeyCode::key_t::KEYCODE_ZOOMRESET },
    { KEYCODE_WORDPROCESSOR_ETS,             KeyCode::key_t::KEYCODE_WORDPROCESSOR },
    { KEYCODE_EDITOR_ETS,                    KeyCode::key_t::KEYCODE_EDITOR },
    { KEYCODE_SPREADSHEET_ETS,               KeyCode::key_t::KEYCODE_SPREADSHEET },
    { KEYCODE_GRAPHICSEDITOR_ETS,            KeyCode::key_t::KEYCODE_GRAPHICSEDITOR },
    { KEYCODE_PRESENTATION_ETS,              KeyCode::key_t::KEYCODE_PRESENTATION },
    { KEYCODE_DATABASE_ETS,                  KeyCode::key_t::KEYCODE_DATABASE },
    { KEYCODE_NEWS_ETS,                      KeyCode::key_t::KEYCODE_NEWS },
    { KEYCODE_VOICEMAIL_ETS,                 KeyCode::key_t::KEYCODE_VOICEMAIL },
    { KEYCODE_ADDRESSBOOK_ETS,               KeyCode::key_t::KEYCODE_ADDRESSBOOK },
    { KEYCODE_MESSENGER_ETS,                 KeyCode::key_t::KEYCODE_MESSENGER },
    { KEYCODE_BRIGHTNESS_TOGGLE_ETS,         KeyCode::key_t::KEYCODE_BRIGHTNESS_TOGGLE },
    { KEYCODE_SPELLCHECK_ETS,                KeyCode::key_t::KEYCODE_SPELLCHECK },
    { KEYCODE_COFFEE_ETS,                    KeyCode::key_t::KEYCODE_COFFEE },
    { KEYCODE_MEDIA_REPEAT_ETS,              KeyCode::key_t::KEYCODE_MEDIA_REPEAT },
    { KEYCODE_IMAGES_ETS,                    KeyCode::key_t::KEYCODE_IMAGES },
    { KEYCODE_BUTTONCONFIG_ETS,              KeyCode::key_t::KEYCODE_BUTTONCONFIG },
    { KEYCODE_TASKMANAGER_ETS,               KeyCode::key_t::KEYCODE_TASKMANAGER },
    { KEYCODE_JOURNAL_ETS,                   KeyCode::key_t::KEYCODE_JOURNAL },
    { KEYCODE_CONTROLPANEL_ETS,              KeyCode::key_t::KEYCODE_CONTROLPANEL },
    { KEYCODE_APPSELECT_ETS,                 KeyCode::key_t::KEYCODE_APPSELECT },
    { KEYCODE_SCREENSAVER_ETS,               KeyCode::key_t::KEYCODE_SCREENSAVER },
    { KEYCODE_ASSISTANT_ETS,                 KeyCode::key_t::KEYCODE_ASSISTANT },
    { KEYCODE_KBD_LAYOUT_NEXT_ETS,           KeyCode::key_t::KEYCODE_KBD_LAYOUT_NEXT },
    { KEYCODE_BRIGHTNESS_MIN_ETS,            KeyCode::key_t::KEYCODE_BRIGHTNESS_MIN },
    { KEYCODE_BRIGHTNESS_MAX_ETS,            KeyCode::key_t::KEYCODE_BRIGHTNESS_MAX },
    { KEYCODE_KBDINPUTASSIST_PREV_ETS,       KeyCode::key_t::KEYCODE_KBDINPUTASSIST_PREV },
    { KEYCODE_KBDINPUTASSIST_NEXT_ETS,       KeyCode::key_t::KEYCODE_KBDINPUTASSIST_NEXT },
    { KEYCODE_KBDINPUTASSIST_PREVGROUP_ETS,  KeyCode::key_t::KEYCODE_KBDINPUTASSIST_PREVGROUP },
    { KEYCODE_KBDINPUTASSIST_NEXTGROUP_ETS,  KeyCode::key_t::KEYCODE_KBDINPUTASSIST_NEXTGROUP },
    { KEYCODE_KBDINPUTASSIST_ACCEPT_ETS,     KeyCode::key_t::KEYCODE_KBDINPUTASSIST_ACCEPT },
    { KEYCODE_KBDINPUTASSIST_CANCEL_ETS,     KeyCode::key_t::KEYCODE_KBDINPUTASSIST_CANCEL },
    { KEYCODE_FRONT_ETS,                     KeyCode::key_t::KEYCODE_FRONT },
    { KEYCODE_SETUP_ETS,                     KeyCode::key_t::KEYCODE_SETUP },
    { KEYCODE_WAKEUP_ETS,                    KeyCode::key_t::KEYCODE_WAKEUP },
    { KEYCODE_SENDFILE_ETS,                  KeyCode::key_t::KEYCODE_SENDFILE },
    { KEYCODE_DELETEFILE_ETS,                KeyCode::key_t::KEYCODE_DELETEFILE },
    { KEYCODE_XFER_ETS,                      KeyCode::key_t::KEYCODE_XFER },
    { KEYCODE_PROG1_ETS,                     KeyCode::key_t::KEYCODE_PROG1 },
    { KEYCODE_PROG2_ETS,                     KeyCode::key_t::KEYCODE_PROG2 },
    { KEYCODE_MSDOS_ETS,                     KeyCode::key_t::KEYCODE_MSDOS },
    { KEYCODE_SCREENLOCK_ETS,                KeyCode::key_t::KEYCODE_SCREENLOCK },
    { KEYCODE_DIRECTION_ROTATE_DISPLAY_ETS,  KeyCode::key_t::KEYCODE_DIRECTION_ROTATE_DISPLAY },
    { KEYCODE_CYCLEWINDOWS_ETS,              KeyCode::key_t::KEYCODE_CYCLEWINDOWS },
    { KEYCODE_COMPUTER_ETS,                  KeyCode::key_t::KEYCODE_COMPUTER },
    { KEYCODE_EJECTCLOSECD_ETS,              KeyCode::key_t::KEYCODE_EJECTCLOSECD },
    { KEYCODE_ISO_ETS,                       KeyCode::key_t::KEYCODE_ISO },
    { KEYCODE_MOVE_ETS,                      KeyCode::key_t::KEYCODE_MOVE },
    { KEYCODE_F13_ETS,                       KeyCode::key_t::KEYCODE_F13 },
    { KEYCODE_F14_ETS,                       KeyCode::key_t::KEYCODE_F14 },
    { KEYCODE_F15_ETS,                       KeyCode::key_t::KEYCODE_F15 },
    { KEYCODE_F16_ETS,                       KeyCode::key_t::KEYCODE_F16 },
    { KEYCODE_F17_ETS,                       KeyCode::key_t::KEYCODE_F17 },
    { KEYCODE_F18_ETS,                       KeyCode::key_t::KEYCODE_F18 },
    { KEYCODE_F19_ETS,                       KeyCode::key_t::KEYCODE_F19 },
    { KEYCODE_F20_ETS,                       KeyCode::key_t::KEYCODE_F20 },
    { KEYCODE_F21_ETS,                       KeyCode::key_t::KEYCODE_F21 },
    { KEYCODE_F22_ETS,                       KeyCode::key_t::KEYCODE_F22 },
    { KEYCODE_F23_ETS,                       KeyCode::key_t::KEYCODE_F23 },
    { KEYCODE_F24_ETS,                       KeyCode::key_t::KEYCODE_F24 },
    { KEYCODE_PROG3_ETS,                     KeyCode::key_t::KEYCODE_PROG3 },
    { KEYCODE_PROG4_ETS,                     KeyCode::key_t::KEYCODE_PROG4 },
    { KEYCODE_DASHBOARD_ETS,                 KeyCode::key_t::KEYCODE_DASHBOARD },
    { KEYCODE_SUSPEND_ETS,                   KeyCode::key_t::KEYCODE_SUSPEND },
    { KEYCODE_HP_ETS,                        KeyCode::key_t::KEYCODE_HP },
    { KEYCODE_SOUND_ETS,                     KeyCode::key_t::KEYCODE_SOUND },
    { KEYCODE_QUESTION_ETS,                  KeyCode::key_t::KEYCODE_QUESTION },
    { KEYCODE_CONNECT_ETS,                   KeyCode::key_t::KEYCODE_CONNECT },
    { KEYCODE_SPORT_ETS,                     KeyCode::key_t::KEYCODE_SPORT },
    { KEYCODE_SHOP_ETS,                      KeyCode::key_t::KEYCODE_SHOP },
    { KEYCODE_ALTERASE_ETS,                  KeyCode::key_t::KEYCODE_ALTERASE },
    { KEYCODE_SWITCHVIDEOMODE_ETS,           KeyCode::key_t::KEYCODE_SWITCHVIDEOMODE },
    { KEYCODE_BATTERY_ETS,                   KeyCode::key_t::KEYCODE_BATTERY },
    { KEYCODE_BLUETOOTH_ETS,                 KeyCode::key_t::KEYCODE_BLUETOOTH },
    { KEYCODE_WLAN_ETS,                      KeyCode::key_t::KEYCODE_WLAN },
    { KEYCODE_UWB_ETS,                       KeyCode::key_t::KEYCODE_UWB },
    { KEYCODE_WWAN_WIMAX_ETS,                KeyCode::key_t::KEYCODE_WWAN_WIMAX },
    { KEYCODE_RFKILL_ETS,                    KeyCode::key_t::KEYCODE_RFKILL },
    { KEYCODE_CHANNEL_ETS,                   KeyCode::key_t::KEYCODE_CHANNEL },
    { KEYCODE_BTN_0_ETS,                     KeyCode::key_t::KEYCODE_BTN_0 },
    { KEYCODE_BTN_1_ETS,                     KeyCode::key_t::KEYCODE_BTN_1 },
    { KEYCODE_BTN_2_ETS,                     KeyCode::key_t::KEYCODE_BTN_2 },
    { KEYCODE_BTN_3_ETS,                     KeyCode::key_t::KEYCODE_BTN_3 },
    { KEYCODE_BTN_4_ETS,                     KeyCode::key_t::KEYCODE_BTN_4 },
    { KEYCODE_BTN_5_ETS,                     KeyCode::key_t::KEYCODE_BTN_5 },
    { KEYCODE_BTN_6_ETS,                     KeyCode::key_t::KEYCODE_BTN_6 },
    { KEYCODE_BTN_7_ETS,                     KeyCode::key_t::KEYCODE_BTN_7 },
    { KEYCODE_BTN_8_ETS,                     KeyCode::key_t::KEYCODE_BTN_8 },
    { KEYCODE_BTN_9_ETS,                     KeyCode::key_t::KEYCODE_BTN_9 },
    { KEYCODE_DAGGER_CLICK_ETS,              KeyCode::key_t::KEYCODE_DAGGER_CLICK },
    { KEYCODE_DAGGER_DOUBLE_CLICK_ETS,       KeyCode::key_t::KEYCODE_DAGGER_DOUBLE_CLICK },
    { KEYCODE_DAGGER_LONG_PRESS_ETS,         KeyCode::key_t::KEYCODE_DAGGER_LONG_PRESS }
};

KeyCode ConvertEtsKeyCode(int32_t keyCode)
{
    auto iter = KEY_CODE_TRANSFORMATION.find(keyCode);
    if (iter == KEY_CODE_TRANSFORMATION.end()) {
        MMI_HILOGE("Find failed, keyCode:%{public}d", keyCode);
        return KeyCode::key_t::KEYCODE_UNKNOWN;
    }
    return iter->second;
}

} // namespace MMI
} // namespace OHOS

// Since these macros are auto-generate, }, lint will cause false positive.
// NOLINTBEGIN
// NOLINTEND